﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ServiceModel;
using Gman.WebApp.GeneralServiceRef;
using Gman.Entity.Entities;
using Gman.WebApp.ServiceControllers;
using AutoMapper;

using System.Collections;

namespace Gman.WebApp.ServiceControllers
{
    public class GeneralServiceController : ServiceControllerBase
    {
        #region Ubigeo

        public IList<UbigeoBE> ListarUbigeo(UbigeoBE oItem, int state)
        {
            List<UbigeoBE> list = new List<UbigeoBE>();

            try
            {
                Request_Ubigeo request = new Request_Ubigeo();
                request.state = state;
                request.UbigeoDTO = oItem;
                request.AccessToken = AccessToken;
                request.ClientTag = ClientTag;
                request.LoadOptions = new string[] { "list" };

                Response_Ubigeo response = GeneralServiceClient.ListarUbigeo(request);
                list.Clear();

                foreach (var x in response.LstUbigeo)
                {
                    list.Add(x);
                }
                list.Insert(0, new UbigeoBE()
                {
                    CodUbigeo = "0",
                    CodDpto = "0",
                    CodProv = "-1",
                    CodDist = "0",
                    DescUbigeo = "Seleccione"
                });

                return list;
            }
            catch (Exception ex)
            {
                throw new Exception("GeneralesBL.listarUbigeo()" + " - " + ex.Message + " - " + ex.InnerException, ex);
            }
        }

        #endregion
    }
}
